﻿using System;
using System.Collections.Generic;
using Assets.Scripts.Net.Data.Model;

namespace Assets.Scripts.Net.Data.Reader
{
    /// <summary>
    /// 问题
    /// </summary>
    public class QueInfoReader:NetInfoReaderBase
    {
        public QueInfoReader(List<object> list, Action<Dictionary<string, string>> action) : base(list, action)
        {
            if (list == null) return;
            Dictionary<string,string>resUrlDict=new Dictionary<string, string>();
            List<QueInfo> infos = new List<QueInfo>();
            for (int i = 0; i < list.Count; i++)
            {
                QueInfo info = new QueInfo();
                Dictionary<string, object> dict = list[i] as Dictionary<string, object>;
                AutoSetValue<QueInfo>(dict, info);
                infos.Add(info);
                //添加问题图片
                if (!string.IsNullOrEmpty(info.respath))
                {
                    //Debug.Log("问题的资源路径："+info.respath);
                    resUrlDict.Add("Q_" + info.id, info.respath);
                }
                //添加解析图片
                if (!string.IsNullOrEmpty(info.analysisfile))
                {
                    resUrlDict.Add("QA_"+info.id,info.analysisfile);
                }
            }
            AddInfoToFactory<List<QueInfo>>(infos);
            if (action != null) action(resUrlDict);
        }
    }
}